package com.zetyun.tiger.connector.ods;

import com.zetyun.rt.meta.annotation.ActionMeta;
import com.zetyun.rt.sdk.action.MapAction;
import com.zetyun.rt.sdk.model.RtEvent;

import java.util.HashMap;
import java.util.Map;

import static com.zetyun.tiger.connector.cdc.CdcConstant.*;


@ActionMeta(
        id = "tiger.ods-data-format",
        tags = {"formatter"},
        category = "map",
        name = "OdsDataFormat",
        description = "此算子上游必须为 FormatAsMaxwellData 算子，此算子目的是根据不同的数据表" +
                "统一进行属性提升，即将 data 字段的 属性提升到顶层"
)
public class OdsDataFormat extends MapAction {

    @Override
    public RtEvent apply(RtEvent rtEvent) throws Exception {


        HashMap data = rtEvent.getField(DATA, HashMap.class);
        if (data != null) {
            rtEvent.putAll(data);
        }

        rtEvent.removeField(DATA);
//        rtEvent.removeField(DATABASE_NAME);
//        rtEvent.removeField(TABLE_NAME);
//        rtEvent.removeField(OP_TYPE);

        return rtEvent;
    }
}
